<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑接口方法参数对象具体参数信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="returnIndex()"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <@permission btnType="save" btnId="saveBtn" btnValue="保存" op="api:facadeObjParam:save"
              btnMethod="ApiFacadeObjParamMgr.submitForm()"/>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>接口方法参数对象具体参数信息</strong>
          </div>
          <form action="/apiFacadeObjParam/saveApiFacadeObjParam" class="form-horizontal" id="apiFacadeObjParamForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input class="form-control" id="id" name="id" type="hidden" value="${apiFacadeObjParam.id!}">
            <input class="form-control" id="objId" name="objId" type="hidden" value="${apiFacadeObjParam.objId!}"/>
            <input class="form-control" id="pojoId" name="pojoId" type="hidden" value="${apiFacadeObjParam.pojoId!}"/>
            <input class="form-control" id="enumId" name="enumId" type="hidden" value="${apiFacadeObjParam.enumId!}"/>
            <div class="form-group">
              <label class="col-sm-2 control-label">参数编码 ：</label>
              <div class="col-sm-2">
                <input class="form-control" id="paramCode" name="paramCode" required="required"
                       type="text"
                       value="${apiFacadeObjParam.paramCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
              <label class="col-sm-2 control-label">描述 ：</label>
              <div class="col-sm-2">
                <input class="form-control" id="paramDesc" name="paramDesc" required="required"
                       type="text" value="${apiFacadeObjParam.paramDesc!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="paramJavaType" dict_desc="参数java类型" dict_key="std_data_java_type"
              dict_value="${apiFacadeObjParam.paramJavaType!}" dict_type="select"
              label_class="col-sm-2 control-label text-right" dict_class="col-sm-2" required="required"
              default_value="03" dict_method="ApiFacadeObjParamMgr.selectObj()"/>
              <div id="enumDiv" style="display:none">
                <label class="col-sm-2 control-label">枚举编码 ：</label>
                <div class="col-sm-2">
                  <input class="form-control" id="enumCode" name="enumCode" readonly="readonly"
                         required="required" type="text" value="${apiFacadeObjParam.enumCode!}"/>
                </div>
                <div class='col-sm-2'>
                  <span class="required">*</span>
                  <input class="primary-btn" id="selectEnum" onclick="ApiFacadeObjParamMgr.selectEnum()" type="button"
                         value='选择enum'/>
                </div>
              </div>
              <div id="pojoDiv" style="display:none">
                <label class="col-sm-2 control-label">参数对象编码 ：</label>
                <div class="col-sm-2">
                  <input class="form-control" id="pojoCode" name="pojoCode" readonly="readonly"
                         required="required" type="text" value="${apiFacadeObjParam.pojoCode!}"/>
                </div>
                <div class='col-sm-2'>
                  <input class="primary-btn" id="selectPojo" onclick="ApiFacadeObjParamMgr.selectPojo()" type="button"
                         value='选择参数对象'/>
                  <span class="required">*</span>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">示例值 ：</label>
              <div class="col-sm-2">
                <input class="form-control" id="paramDemo" name="paramDemo" required="required"
                       type="text" value="${apiFacadeObjParam.paramDemo!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
              <label class="col-sm-2 control-label">最大长度 ：</label>
              <div class="col-sm-2">
                <input class="form-control" digits="true" id="maxLength" name="maxLength"
                       required="required" type="text" value="${apiFacadeObjParam.maxLength!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isRequired" dict_desc="是否必填" dict_key="std_zb_yn"
              dict_value="${apiFacadeObjParam.isRequired!}" dict_type="select"
              label_class="col-sm-2 control-label text-right" dict_class="col-sm-2" required="required"
              default_value="Y"/>
              <@PageDict dict_name="isList" dict_desc="是否返回list列表" dict_key="std_zb_yn"
              dict_value="${apiFacadeObjParam.isList!}" dict_type="select"
              label_class="col-sm-2 control-label text-right" dict_class="col-sm-2" required="required"
              default_value='N'/>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>

<#include "/common/jslib.html">
<!-- 弹窗下拉 -->
<script type="text/javascript">
    function returnIndex() {
        var objId = $("#objId").val();
        window.location.href = "/apiFacadeObj/to-tab?operation=edit&id=" + objId;
    }

    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        // 弹出窗体控制
        ApiFacadeObjParamMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                }
            },
            // init end

            // 提交数据
            submitForm: function () {
                Jmts.ajaxSubmit(document.getElementById("apiFacadeObjParamForm"), function (result) {
                    if (result.success) {
                        if (operation == 'add') {
                            var objId = $("#objId").val();
                            window.location.href = "/apiFacadeObj/to-tab?operation=edit&id=" + objId;
                        } else {
                            Jmts.succTips(result.msg);
                            window.location.reload();
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            returnIndex: function () {
                window.location.href = "/apiFacadeObjParam/query";
            },
            selectObj: function () {//选择枚举或pojo对象
                var paramJavaType = $("#paramJavaType").val();
                if (paramJavaType == "12") {//enum
                    $("#enumDiv").show();
                    $("#pojoDiv").hide();
                    $("#enumDiv").attr("required", true);
                    $("#pojoDiv").attr("required", false);
                    $("#pojoDiv").val("");
                } else if (paramJavaType == "13" || paramJavaType == "14" || paramJavaType == "15") {//pojo,request,response
                    $("#pojoDiv").show();
                    $("#enumDiv").hide();
                    $("#enumDiv").attr("required", false);
                    $("#pojoDiv").attr("required", true);
                    $("#enumDiv").val("");
                }
            },
            selectEnum: function () {//选择枚举
                var url = "/apiFacadeObjEnum/query_select?selectType=single&returnMethod=ApiFacadeObjParamMgr.loadEnum";
                Jmts.openDialog("selectEnum", url, "选择enum信息", 500, 800, 32);
            },
            selectPojo: function () {//选择pojo
                var objType = "";
                var paramJavaType = $("#paramJavaType").val();
                if (paramJavaType == "13") {
                    objType = "pojo";
                } else if (paramJavaType == "14") {
                    objType = "request";
                } else if (paramJavaType == "15") {
                    objType = "response";
                }
                var url = "/apiFacadeObj/query_select?selectType=single&returnMethod=ApiFacadeObjParamMgr.loadPojo&objType=" + objType;
                Jmts.openDialog("selectPojo", url, "选择参数对象信息", 500, 800, 32);
            },
            loadPojo: function (data) {//加载pojo
                var pojos = data.split("#");
                $("#pojoId").val(pojos[0]);
                $("#pojoCode").val(pojos[1]);
            },
            loadEnum: function (data) {//加载enum
                var enums = data.split("#");
                $("#enumId").val(enums[0]);
                $("#enumCode").val(enums[1]);
            }
        };
        // 执行初始化
        ApiFacadeObjParamMgr.init();
        // 前台验证表单
        $("#apiFacadeObjParamForm").validate();
    });
</script>
</body>
</html>
